🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / service / src / androidMain / kotlin / org / meshtastic / core / service / AndroidFileService.kt
Displaying Raw • Download
core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidFileService.kt fix/qr-error-correction (7b45f84f) Text, 2.70 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.service
Tff7b72import T7ee787android.app.Application
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787com.eygraber.uri.toAndroidUri
Tff7b72import T7ee787kotlinx.coroutines.withContext
Tff7b72import T7ee787okio.BufferedSink
Tff7b72import T7ee787okio.BufferedSource
Tff7b72import T7ee787okio.buffer
Tff7b72import T7ee787okio.sink
Tff7b72import T7ee787okio.source
Tff7b72import T7ee787org.koin.core.annotation.Single
Tff7b72import T7ee787org.meshtastic.core.common.util.CommonUri
Tff7b72import T7ee787org.meshtastic.core.di.CoroutineDispatchers
Tff7b72import T7ee787org.meshtastic.core.repository.FileService
Tff7b72import T7ee787java.io.FileOutputStream
Tf0883e@Single
Tff7b72class T56d364AndroidFileServiceTb4b4b4(Tff7b72private Tff7b72val Te6edf3contextTb4b4b4: Te6edf3ApplicationTb4b4b4, Tff7b72private Tff7b72val Te6edf3dispatchersTb4b4b4: Te6edf3CoroutineDispatchersTb4b4b4) Tb4b4b4:
Te6edf3FileService Tb4b4b4{
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffwriteTb4b4b4(Te6edf3uriTb4b4b4: Te6edf3CommonUriTb4b4b4, Te6edf3blockTb4b4b4: Te6edf3suspend Tb4b4b4(Te6edf3BufferedSinkTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72=
Te6edf3withContextTb4b4b4(Te6edf3dispatchersTb4b4b4.Te6edf3ioTb4b4b4) Tb4b4b4{
Tff7b72try Tb4b4b4{
Tff7b72val Te6edf3pfd Tff7b72= Te6edf3contextTb4b4b4.Te6edf3contentResolverTb4b4b4.Te6edf3openFileDescriptorTb4b4b4(Te6edf3uriTb4b4b4.Te6edf3toAndroidUriTb4b4b4(Tb4b4b4)Tb4b4b4, Ta5d6ff"Ta5d6ffwtTa5d6ff"Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3pfd Tff7b72=Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3e Tb4b4b4{ Ta5d6ff"Ta5d6ffFailed to obtain file descriptor for URI: Tffd700$Te6edf3uriTa5d6ff" Tb4b4b4}
Tff7b72returnTf0883e@withContext Tff7b72false
Tb4b4b4}
Te6edf3pfdTb4b4b4.Te6edf3use Tb4b4b4{ Te6edf3descriptor Tff7b72-Tff7b72>
Te6edf3FileOutputStreamTb4b4b4(Te6edf3descriptorTb4b4b4.Te6edf3fileDescriptorTb4b4b4)Tb4b4b4.Te6edf3sinkTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3bufferTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3use Tb4b4b4{ Te6edf3sink Tff7b72-Tff7b72> Te6edf3blockTb4b4b4(Te6edf3sinkTb4b4b4) Tb4b4b4}
Tb4b4b4}
Tff7b72true
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3eTb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3eTb4b4b4(Te6edf3eTb4b4b4) Tb4b4b4{ Ta5d6ff"Ta5d6ffFailed to write to URI: Tffd700$Te6edf3uriTa5d6ff" Tb4b4b4}
Tff7b72false
Tb4b4b4}
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffreadTb4b4b4(Te6edf3uriTb4b4b4: Te6edf3CommonUriTb4b4b4, Te6edf3blockTb4b4b4: Te6edf3suspend Tb4b4b4(Te6edf3BufferedSourceTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72=
Te6edf3withContextTb4b4b4(Te6edf3dispatchersTb4b4b4.Te6edf3ioTb4b4b4) Tb4b4b4{
Tff7b72try Tb4b4b4{
Tff7b72val Te6edf3success Tff7b72=
Te6edf3contextTb4b4b4.Te6edf3contentResolverTb4b4b4.Te6edf3openInputStreamTb4b4b4(Te6edf3uriTb4b4b4.Te6edf3toAndroidUriTb4b4b4(Tb4b4b4)Tb4b4b4)Tff7b72?.Te6edf3use Tb4b4b4{ Te6edf3inputStream Tff7b72-Tff7b72>
Te6edf3inputStreamTb4b4b4.Te6edf3sourceTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3bufferTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3use Tb4b4b4{ Te6edf3source Tff7b72-Tff7b72> Te6edf3blockTb4b4b4(Te6edf3sourceTb4b4b4) Tb4b4b4}
Tff7b72true
Tb4b4b4} Tff7b72?: Tff7b72false
Te6edf3success
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3eTb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3eTb4b4b4(Te6edf3eTb4b4b4) Tb4b4b4{ Ta5d6ff"Ta5d6ffFailed to read from URI: Tffd700$Te6edf3uriTa5d6ff" Tb4b4b4}
Tff7b72false
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s